625B - War of the Corporations - CodeForces Solution


constructive algorithms greedy strings *1200

Please click on ads to support us..

C++ Code:

///In the name of Allah, the most Gracious and the most Merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fr first
#define sc second
#define IShowSpeed ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std ;

ll n, m, a, b, k, x, ans, cnt, sum ;
vector < ll > v, v1, vv ;
map < ll, ll > mp ;
string s, s1, ss ;

void algorithm()
{
    ///www.youtube.com/watch?v=ZYaZ6Odbx_Y
    cin >> s >> s1 ;
    if ( s1.size() > s.size() ) {
        cout << "0" ;
        return ;
    }
    for ( int i = 0 ; i < s.size() ; i ++ )
    {
        ss += s [ i ] ;
        if ( ss.size() == s1.size() )
        {
            if ( ss ==s1 ){
                ss.clear() ;
                ans ++ ;
            }
            else {
                ss.erase ( ss.begin() ) ;
            }
        }
    }
    cout << ans ;
}

//@author: FeaRL3ss

int main()
{
    IShowSpeed
    ll q = 1 ;
    ///cin >> q ;
    while ( q -- )
    {
        algorithm() ;
    }
}
///So remember me , I will remember you [ Quran 2:152 ]


Comments

Submit
0 Comments
More Questions

231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality
1650C - Weight of the System of Nested Segments
1097A - Gennady and a Card Game
248A - Cupboards
1641A - Great Sequence
1537A - Arithmetic Array
1370A - Maximum GCD
149A - Business trip
34A - Reconnaissance 2
59A - Word